from flask import Flask,url_for,request,render_template
from nlpfc import query
from summarization import abstract_fc
# from flask import Flask,render_template
app = Flask(__name__)

@app.route("/")#主页设置为“0.0.0.0”以使服务器在外部可用
def index():
    return render_template('index.html')
@app.route('/', methods=['POST', 'GET'])
def my_form_post():
    text = request.form ['text'] 
    print(text)
    print(type(text))
    output = query({#生成式摘要输出结果
    "inputs": text
})
    output1 = abstract_fc(text)#抽取式摘要输出结果
    
    print(output)
    
    return render_template('index.html',variable=output,variable_textrank=output1)
    # if request.method == 'POST':
    #     if request.form['user'] == 'admin':
    #         return 'Admin login successfully!'
    #     else:
    #         return 'No such user!'
# if request.method == "POST":   
#     username = request.values.get("username")
#     sex = request.values.get("sex")
if __name__ == "__main__":
    app.run() #app.run(host, port, debug, options) 
    #基本参数设置解释
    #https://www.w3cschool.cn/flask/flask_application.html

